package the.guanzhong.express.interfaces.controller;

import com.alibaba.fastjson.JSON;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.wisteria.framework.web.APIResult;
import the.broccoli.setting.service.IParamsService;
import the.guanzhong.express.interfaces.controller.resp.ShopListResp;

import javax.annotation.Resource;
import java.util.List;

/**
 * 门店控制器
 */
@Api(tags = "Express")
@Slf4j
@RestController
@RequestMapping("/express/shop")
public class ExpressShopController {

    @Resource
    private IParamsService paramsService;

    /**
     * 门店列表
     * @return
     */
    @PostMapping("/list")
    public APIResult<List<ShopListResp>> getShopList() {
        List<ShopListResp> dataList = null;
        String content = paramsService.getValue("EXPRESS_SHOP");
        if (StringUtils.hasText(content)) {
            dataList = JSON.parseArray(content, ShopListResp.class);
        }
        return APIResult.success(dataList);
    }
}
